// 车辆管理 - 档案完善
import { pget, ppostFileByFormData, ppostJson } from '@/utils/req'
import { modalApi } from '@/utils/modalReq'

/**
 * 规则列表
 * @param query
 * @returns
 */
export function getTableList(query: any) {
	return pget(`${modalApi.marketing}/marketingrewardrules/page`, query)
}

/**
 * 商品方案选择司机奖励列表
 * @param query
 * @returns
 */
export function getShopList(query: any) {
	return pget(`${modalApi.marketing}/marketingrewardrules/rulespage`, query)
}

/**
 * 新增奖励规则
 * @param data
 * @returns
 */
export function addSaveReward(data: any) {
	return ppostJson(`${modalApi.marketing}/marketingrewardrules/save`, data)
}

/**
 * 更新奖励规则
 * @param data
 * @returns
 */
export function updateSaveReward(data: any) {
	return ppostJson(`${modalApi.marketing}/marketingrewardrules/update`, data)
}

/**
 * 【司机】获得商品方案列表
 * @param params
 * @returns
 */
export async function getRelevanceShop(params: any): Promise<any> {
	return ppostJson(
		`${modalApi.marketing}/shopec-marketing/commodity-scheme/listByParamsWithBrandRentsTypes`,
		params,
	)
}

// 获取主体公司
export function getMainCompanyList() {
	return pget(`${modalApi.system}/common/subject-merchant/all`)
}

/**
 *
 * @returns 获取规则详情
 */
export function getInitFormDetail(query: any) {
	return pget(`${modalApi.marketing}/marketingrewardrules/detail`, query)
}

/**
 *
 * @returns 获取商品方案详情
 */
export function getInitFormDetailShop(query: any) {
	return pget(
		`${modalApi.marketing}/marketingrewardrules/rewardCommodityPage`,
		query,
	)
}

/**
 *
 * @param data 批量或者单个审核
 * @returns
 */
export function processAudit(data: any) {
	return ppostJson(
		`${modalApi.marketing}/marketingrewardrules/processAuditSuccess`,
		data,
	)
}

/**
 *
 * @param query 查询审核记录
 * @returns
 */
export function auditLogging(query: any) {
	return pget(`${modalApi.marketing}/marketingrewardrules/processList`, query)
}

/**
 *
 * @param data 导出列表数据
 * @returns
 */
export function exportReward(data: any) {
	return ppostJson(
		`${modalApi.marketing}/marketingrewardrules/exporRewardRules`,
		data,
	)
}

/**
 *
 * @param query 查询导入数据异常列表
 * @returns
 */
export function getExportErrorData(query: any) {
	return pget(
		`${modalApi.marketing}/marketingrewardrules/errorRulesPage`,
		query,
	)
}

/**
 *
 * @param query 获取操作记录日志
 * @returns
 */
export function getOperatingRecord(query: any) {
	return pget(`${modalApi.common}/operatelog/list`, query)
}

/**
 *
 * @param data 导入数据
 * @returns
 */
export function importReward(data: any) {
	return ppostFileByFormData(
		`${modalApi.marketing}/marketingrewardrules/marketingRewardRulesImport`,
		data,
	)
}

export const importCheckReward = `${modalApi.marketing}/marketingrewardrules/marketingRewardRulesImport`;

/**
 *
 * @param data 启用/禁用
 * @returns
 */
export function updateStatus(data: any) {
	return ppostJson(
		`${modalApi.marketing}/marketingrewardrules/updateStatus`,
		data,
	)
}